<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Crawler::LastfmCrawler</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Crawler::LastfmCrawler</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/lib/crawler/lastfm_crawler_rb.html">
                lib/crawler/lastfm_crawler.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="Crawler.html">
                Crawler
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000014">crawl</a>&nbsp;&nbsp;
      <a href="#M000013">crawl_table</a>&nbsp;&nbsp;
      <a href="#M000011">new</a>&nbsp;&nbsp;
      <a href="#M000012">service_name</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000011" class="method-detail">
        <a name="M000011"></a>

        <div class="method-heading">
          <a href="#M000011" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(args = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000011-source">
<pre>
    <span class="ruby-comment cmt"># File lib/crawler/lastfm_crawler.rb, line 9</span>
 9:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">args</span> = {})
10:       <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">args</span>)
11:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000014" class="method-detail">
        <a name="M000014"></a>

        <div class="method-heading">
          <a href="#M000014" class="method-signature">
          <span class="method-name">crawl</span><span class="method-args">(c)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000014-source">
<pre>
    <span class="ruby-comment cmt"># File lib/crawler/lastfm_crawler.rb, line 22</span>
22:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">crawl</span>(<span class="ruby-identifier">c</span>)
23:       <span class="ruby-identifier">request_uri</span> = <span class="ruby-node">&quot;http://ws.audioscrobbler.com/2.0/?method=user.getinfo&amp;user=#{URI.escape(c.service.uername_on_service)}&amp;api_key=b25b959554ed76058ac220b7b2e0a026&quot;</span>
24:       <span class="ruby-ivar">@curl</span>.<span class="ruby-identifier">url</span> = <span class="ruby-identifier">request_uri</span>
25:       <span class="ruby-identifier">response</span> = <span class="ruby-keyword kw">false</span>
26:       
27:       <span class="ruby-keyword kw">begin</span>
28:         <span class="ruby-ivar">@curl</span>.<span class="ruby-identifier">http_get</span>    
29:         <span class="ruby-identifier">c</span>.<span class="ruby-identifier">status</span> = <span class="ruby-ivar">@curl</span>.<span class="ruby-identifier">response_code</span>
30:         <span class="ruby-identifier">response</span> = <span class="ruby-ivar">@curl</span>.<span class="ruby-identifier">response_code</span> <span class="ruby-operator">==</span> <span class="ruby-value">200</span>
31:         <span class="ruby-identifier">c</span>.<span class="ruby-identifier">body</span> = <span class="ruby-ivar">@curl</span>.<span class="ruby-identifier">body_str</span>
32:         <span class="ruby-identifier">c</span>.<span class="ruby-identifier">crawled_at</span> = <span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">now</span>
33:       <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Curl</span><span class="ruby-operator">::</span><span class="ruby-constant">Err</span><span class="ruby-operator">::</span><span class="ruby-constant">GotNothingError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
34:         <span class="ruby-identifier">response</span> = <span class="ruby-keyword kw">false</span>
35:         <span class="ruby-identifier">p</span> <span class="ruby-identifier">request_uri</span>
36:       <span class="ruby-keyword kw">end</span>
37:       <span class="ruby-identifier">c</span>.<span class="ruby-identifier">save</span>
38:       <span class="ruby-identifier">response</span>
39:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000013" class="method-detail">
        <a name="M000013"></a>

        <div class="method-heading">
          <a href="#M000013" class="method-signature">
          <span class="method-name">crawl_table</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000013-source">
<pre>
    <span class="ruby-comment cmt"># File lib/crawler/lastfm_crawler.rb, line 17</span>
17:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">crawl_table</span>
18:       <span class="ruby-constant">LastfmCrawl</span>  
19:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000012" class="method-detail">
        <a name="M000012"></a>

        <div class="method-heading">
          <a href="#M000012" class="method-signature">
          <span class="method-name">service_name</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000012-source">
<pre>
    <span class="ruby-comment cmt"># File lib/crawler/lastfm_crawler.rb, line 13</span>
13:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">service_name</span>
14:       <span class="ruby-value str">'lastfm'</span>
15:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>